﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BwanaBank.BankOnline.WinUI.Window.Account
{
    public partial class Account : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["userInfo"] == null && Session["userInfo"] == null)
            {
                Response.Redirect("~/");
            }
            var cn = new SqlConnection(@"Data Source=PAR-ROBHED-001\SQLEXPRESS;Initial Catalog=BWANABANk;Integrated Security=True");
            cn.Open();
            SqlCommand cmd = null;
            if (Request.Cookies["userInfo"] != null)
            {
                cmd = new SqlCommand("SELECT * FROM [User] WHERE customerNUm='" + Request.Cookies["userInfo"].Value + "'", cn);
            }
            else if (Session["userInfo"] != null)
            {
                cmd = new SqlCommand("SELECT * FROM [User] WHERE customerNum='" + Session["userInfo"] + "'", cn);
            }
            var dtr = cmd.ExecuteReader();
            if (dtr.Read())
            {
                Name.Text = (string)dtr["lastName"];
                FirstName.Text = (string)dtr["firstName"];
                dtr.Dispose();
                dtr.Close();
            }
            cn.Close();

        }
    }
}
